package logic

import (
	"context"
	"course-admin/userrpc/userrpc"

	"course-admin/api/internal/svc"
	"course-admin/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type SandLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSandLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SandLogic {
	return &SandLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *SandLogic) Sand(req *types.SandRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	sand, err := l.svcCtx.UserRpc.Sand(l.ctx, &userrpc.SandRequest{Mobile: req.Mobile})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}
	return &types.Response{
		Message: "发送成功",
		Data:    sand,
		Code:    200,
	}, nil
}
